<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Face 列表</title>
  <style>
    body {
      font-family: 'Microsoft YaHei', sans-serif;
      background-color: #f8f9fa;
      padding: 20px;
    }

    h1 {
      text-align: center;
      margin: 20px 0;
      color: #343a40;
    }

    .card {
      background: white;
      border-radius: 8px;
      box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
      margin: 15px 0;
      padding: 15px;
      display: flex;
      flex-direction: row;
      gap: 15px;
    }

    .info {
      display: flex;
      flex-direction: column;
      justify-content: center;
    }

    .name {
      font-size: 18px;
      font-weight: bold;
      color: #333;
      margin-bottom: 5px;
    }

    .password {
      font-size: 16px;
      color: #666;
    }

    .photo {
      flex-shrink: 0;
    }

    .photo img {
      width: 120px;
      height: 120px;
      object-fit: cover;
      border-radius: 8px;
    }

    @media (max-width: 576px) {
      .card {
        flex-direction: column;
        align-items: center;
      }
      
      .photo img {
        width: 100%;
        height: auto;
      }
    }
  </style>
</head>

<body>
  <h1>人脸信息列表</h1>
  <div id="imageList"></div>

  <script>
    fetch('http://localhost:5004/list')
      .then(response => response.json())
      .then(data => {
        if (data.success) {
          const container = document.getElementById('imageList');
          
          data.data.forEach(item => {
            const card = document.createElement('div');
            card.className = 'card';
            
            const infoDiv = document.createElement('div');
            infoDiv.className = 'info';
            
            const nameSpan = document.createElement('div');
            nameSpan.className = 'name';
            nameSpan.textContent = `姓名：${item.Name}`;
            
            const passwordSpan = document.createElement('div');
            passwordSpan.className = 'password';
            passwordSpan.textContent = `密码：${item.Password}`;
            
            const photoDiv = document.createElement('div');
            photoDiv.className = 'photo';
            
            const img = document.createElement('img');
            img.src = `data:image/png;base64,${item.Image}`;
            img.alt = `${item.Name}的照片`;
            
            infoDiv.appendChild(nameSpan);
            infoDiv.appendChild(passwordSpan);
            photoDiv.appendChild(img);
            card.appendChild(infoDiv);
            card.appendChild(photoDiv);
            container.appendChild(card);
          });
        } else {
          alert('加载失败：' + data.error);
        }
      })
      .catch(error => console.error('请求失败：', error));
  </script>
</body>

</html>